﻿using System;

namespace Basmus.ReadWrite
{
    public class Int32ReaderWriter : IReaderWriter<int>
    {
        public ReadResult<int> Read(string s)
        {
            Int32 value;
            if (Int32.TryParse(s, out value))
            {
                return ReadResult<Int32>.Success(value);
            }
            return ReadResult<Int32>.Error();
        }

        public string Write(int value)
        {
            return value.ToString();
        }
    }
}